package com.missilike.admin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.missilike.biz.IMilAccountContentService;
import com.missilike.core.result.CommonResult;
import com.missilike.core.utils.ResultUtils;
import com.missilike.domain.request.MilAccountContentStatusForm;
import com.missilike.domain.request.MilAccountStatusForm;
import com.missilike.domain.response.MilAccountInfo;
import com.missilike.repository.entity.MilAccountContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kin
 * @since 2018-12-25
 */
@RestController
@RequestMapping("/api/mil/content")
public class MilAccountContentController {

    private final IMilAccountContentService milAccountContentService;

    @Autowired
    public MilAccountContentController(IMilAccountContentService milAccountContentService) {
        this.milAccountContentService = milAccountContentService;
    }

    @RequestMapping(value = "page", method = RequestMethod.GET)
    public CommonResult list(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                             @RequestParam(value = "pageSize", required = false, defaultValue = "20") int pageSize) {
        IPage<MilAccountContent> contentList = milAccountContentService.getList(new Page<>(pageNum, pageSize));
        return ResultUtils.ok(contentList);
    }

    @RequestMapping(value = "status", method = RequestMethod.POST)
    public CommonResult status(@RequestBody MilAccountContentStatusForm milAccountContentStatusForm) {
        milAccountContentService.status(milAccountContentStatusForm);
        return ResultUtils.ok();
    }

}

